<template>
    <div class="acceptance-registration-pages">
        <commpVxeTable
         :config="dataTableConfig" 
         :columns="columnsVxe" 
         :formItem="formItem"
         @checkboxChange="checkboxChange"
         ref="acceptanceRegistrationRef"
         >
            <template v-slot:externalOperations="{data}"  >
                <vxe-form-item>
                    <template>
                        <a-button class="blue-btn" type="primary" @click="addition()">新增</a-button>
                    </template>
                </vxe-form-item>
                <!-- <vxe-form-item>
                    <template>
                        <a-button class="blue-btn" type="primary" @click="batchDeletion()">批量删除</a-button>
                    </template>
                </vxe-form-item> -->
            </template>
            
            <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                <a-form layout="inline" class="search-form" >
                    <a-form-item >
                        <a-button class="blue-btn" type="primary" @click="reviseClick(row)">编辑</a-button>
                    </a-form-item>
                    <a-form-item >
                        <a-button class="blue-btn" type="primary" @click="empowerClick(row)">授权</a-button>
                    </a-form-item>
                    <a-form-item >
                        <a-button class="red-btn" type="primary" @click="batchDeletion(row)">删除</a-button>
                    </a-form-item>
                </a-form>
            </template>
        </commpVxeTable>
        <increase ref="increaseRef" @handleOk="handleOk"/>
        <roleAuthorization ref="roleAuthorizationRef" @handleOk="handleOk"/>
    </div>
</template>
<script>
import {typeInput, typeNumber, typeSelect, typeCheckbox, typeRadio} from '@/components/compSearchCriteria/ContractType'
import assessCheckApi from './service/api.js'
import increase from './increase.vue'
import roleAuthorization from './roleAuthorization.vue'
import { deleteArrServe, ocalityPostAction, queryAllYwflFlowJob } from './service/index'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import moment from 'moment'
import blobType from '@/common/blobType'
import compSelector from '@/components/compSelector/compSelector'
  export default {
    components:{
        commpVxeTable,
        increase,
        compSelector,
        roleAuthorization
    },
    
    data(){
        return{
            addEditParameter:{},
            formItem:[
                {
                    label: '名称',
                    model: 'fmc',
                },{
                    label: '是否有效',
                    model: 'fsfyx',
                    type:'Select',
                    options:[{
                        label:'是',
                        value:'是'
                    },{
                        label:'否',
                        value:'否'
                    }]
                }

            ],
            columnsVxe:[{ type: 'checkbox', width: 60 ,fixed: 'left',},{
                    title: '名称', //列头显示文字
                    field: 'fmc',
                },{
                    title: '类型', //列头显示文字
                    field: 'flj',
                },{
                    title: '是否有效',
                    field: 'fsfyx',
                },{
                    title: '操作',
                    field: 'id',
                    slots: {
                    // 使用插槽模板渲染
                    default: 'operation_btn',
                  },
                    fixed: 'right',
                    width:300,
                }],
            dataTableConfig:{
                api: assessCheckApi.list,
                rowId: 'id',
                // fywflcode:blobType.fywflcodeArr[blobType.menuType.indexOf(this.$route.name.substring(this.$route.name.indexOf('__'),this.$route.name.indexOf('_a')+2))],
                paramet:{
                }
            },
            specifyDateVal:'',
            isSpecifyDate:false,
            numFigure:1,
            numFigureVisible:false,
            currentReplicationId:'',
            selectedRowKeysArr:[],
        }
    },
    
    methods:{
        timeProcessing(val){
            if(val){
                val = val.slice(0,11)
            }
            return val
        },
        async dictionaryQuery(val){
            let dataObj = []
            await ocalityPostAction({dictName:val}).then(res=>{
                //console.log('字典的res',res)
                if(res.code == 200){
                    if(res.result.length){
                        dataObj = res.result
                    }
                    
                }
            })
            return dataObj
        },
        checkboxChange(val){//获取当前选择的行
            this.selectedRowKeysArr = []
            val.forEach(item => {
                this.selectedRowKeysArr.push(item.id)
            });
        },
        addition(){//新增
            this.$refs.increaseRef.visibleShow = true
            this.$refs.increaseRef.getData({fsfyx:'是',flj:'普通'})
        },
        //编辑
        reviseClick(val){
            queryAllYwflFlowJob().then(res=>{
                //console.log(res)
            })
            this.$refs.increaseRef.visibleShow = true
            this.$refs.increaseRef.getData(val)
        },
        successReturn(){
            this.$refs.acceptanceRegistrationRef.searchEvent()
        },
        empowerClick(row){//授权
            this.$refs.roleAuthorizationRef.authorizationVisibleShow = true
            this.$refs.roleAuthorizationRef.getData(row)
        },
        batchDeletion(row){//
            var that = this
            if(row || that.selectedRowKeysArr.length){
                this.$confirm({
                    title:'您确认要删除吗？',
                    // icon: createVNode(ExclamationCircleOutlined),
                    onOk() {
                        let deleteString = row?row.id:that.selectedRowKeysArr.join(',')
                        deleteArrServe({id:deleteString}).then(res=>{
                            if(res.code == 200){
                                that.$message.success('删除成功')
                            }else{
                                that.$message.warning(res.message)
                            }              
                            that.$refs.acceptanceRegistrationRef.searchEvent()
                        })
                        
                    },
                    
                });
            }else{
                    that.$message.warning('请选择删除项')
            }
            
            
        },
        handleOk(val,id){
            if(val && !id){
                this.$refs.acceptanceRegistrationRef.resetEvent()
            }else if(val && id){
                this.requestParams = {
                    ...this.requestParams,
                    renovate:true,
                }
            }
            
        },
        AddHandleOk(){
            this.$refs.acceptanceRegistrationRef.resetEvent()
        },
    },

  }
</script>
<style lang="less">
.acceptance-registration-pages{
    .select-date-box{
        display: flex;
        flex-direction: column;
        span{
            color: #f5222d;
            font-size: 14px;
        }
    }
    .modal-btn-box{
        .ant-form-item-control{
            width: 175px !important;
        }
    }
    
}
</style>
<style scoped >
.observer-lbrary-pages{
    background: #fff;
}
.btn-box{
    display: flex;
    justify-content: flex-end;
}
.blue-btn{
    border: 1px solid #5ca3e5 !important;
    background-color: #5ca3e5 !important;
    color: #fff !important;
}
.red-btn{
    border: 1px solid #ed5565 !important;
    background-color: #ed5565 !important;
}




</style>